<template>
  <div class="login-container">
    <h2>登录</h2>
    <form @submit.prevent="IsLogin">
      <div class="input-group">
        <label for="username">账号</label>
        <input type="text" id="username" v-model="username" required />
      </div>
      <div class="input-group">
        <label for="password">密码</label>
        <input type="password" id="password" v-model="password" required />
      </div>
      <button type="submit">登录</button>
    </form>
  </div>
</template>

<script>
import { useCounterStore } from '@/stores/counter'
export default {
  name: 'LoginView',
  data() {
    return {
      username: '',
      password: ''
    };
  },
  methods: {
    IsLogin() {
      if (this.username === 'admin' && this.password === '123') {
        useCounterStore().setUserInfo({
          id: 1,
          name:"张三"
        });
      }else {
        alert('登录失败！');
      }
    }
  }
};
</script>

<style scoped>
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #ff7e5f, #feb47b);
  color: white;
  font-family: Arial, sans-serif;
}

h2 {
  margin-bottom: 20px;
}

form {
  display: flex;
  flex-direction: column;
  width: 300px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.input-group {
  margin-bottom: 15px;
}

label {
  margin-bottom: 5px;
  font-weight: bold;
}

input {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

button {
  padding: 10px;
  border: none;
  border-radius: 5px;
  background: #ff7e5f;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
}

button:hover {
  background: #feb47b;
}
</style><style>
  h1 {
    color: red;
  }
</style>
